require "test/unit"
require_relative "require_helper"

include PDEHeadlessUtil

class TestPDEInputParser < Test::Unit::TestCase

	def setup
		test_input_file = get_test_data "demo_build_input.xml"
		@result = PDEHeadlessBuildInfo.parse_input(test_input_file)
	end

	must "contain 2 svn info" do
		assert_equal @result.m_svn_infoes.size, 2
	end

	must "match property in first svn info" do

		first_svn_info = @result.m_svn_infoes[0] 
		assert_equal first_svn_info.m_revision , "7"
		assert_equal first_svn_info.m_dir_features, "features"
		assert_equal first_svn_info.m_url, "http://localhost/svn_framework/trunk/Source/studio_framework"
		assert_equal first_svn_info.m_url_alias, "studio_framework"
		assert_equal first_svn_info.m_feature_IDs[0],"framework.p1.feature"

	end

	must "match property in second svn info" do
		second_svn_info = @result.m_svn_infoes[1]
		assert_equal second_svn_info.m_revision, "15"
		assert_equal second_svn_info.m_dir_features, "features"
		assert_equal second_svn_info.m_feature_IDs[0],"com.test.svn.p1.feature"
	end

	must "match global setting" do
		global_setting = @result.m_global_setting
		puts global_setting.m_build_timestamp
		assert_equal global_setting.m_username, "xuzhen"
		assert_equal global_setting.m_password, "dd"
	end

	must "match global setting build type" do

		global_setting = @result.m_global_setting
		assert_equal global_setting.m_build_type, "ReleaseBuild"
	end
end


